using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class Ui_toolTip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public ToolTipPos toolTipPos;
    public Transform _tag;
    public float offset = 135f;
    public string cnotent;

    private Vector3 tagPos;
    private Vector3 hidePos = new Vector3(100000, 100000, 100000);

    private void Start()
    {
        tagPos = Vector3.zero;

        switch (toolTipPos)
        {
            case ToolTipPos.Down: tagPos.y -= offset; break;
            case ToolTipPos.Up: tagPos.y += offset; break;
            case ToolTipPos.Left: tagPos.x -= offset; break;
            case ToolTipPos.Right: tagPos.x += offset; break;
        }
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        _tag.GetComponentInChildren<Text>().text = cnotent;
        _tag.SetParent(transform);
        _tag.localPosition = tagPos;
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        _tag.SetParent(null);
        _tag.position = hidePos;
    }
}

public enum ToolTipPos
{
    Down,
    Up,
    Left,
    Right
}